<!DOCTYPE html>
<html xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1">
	<meta name="description" content="A fully featured admin theme which can be used to build CRM, CMS, etc.">
	<meta name="author" content="Coderthemes">
	
	<!-- jQuery  -->
	<script src="/js/jquery3/jquery.min.js"></script>
	
	<!-- layui  -->
	<link rel="stylesheet" href="/js/layuiadmin-1.2.1/layui2.7.6/css/layui.css" media="all" />
	<script type="text/javascript" src="/js/layuiadmin-1.2.1/layui2.7.6/layui.js"></script>
	
	<!-- 打印控件 -->
	<script src="/js/printWorld/PrintWorld.js"></script>
</head>

<body>
	<form class="layui-form" id="id_form" method="post" action="">
		
		<table id="id_table_fenxiang"></table>
		<script th:inline="javascript">
		layui.use(['table', 'dropdown'], function(){
			var dom = $('#id_table_fenxiang');
			layui.table.render({
				elem: '#' + dom.attr('id'),
				limit: 9999,
				id: dom.attr('id'),
				rowDrag: {
					done: function(obj) {}
				},
				totalRow: true,
				cols: [ [
						{field: 'code', title: '商品编码', align:'center'},
						{field: 'name', title: '商品名称', align:'center'},
						{field: 'asin', title: 'ASIN', align:'center'},
						{field: 'sku', title: 'SKU', align:'center'},
						{field: 'fnsku', title: 'FNSKU', align:'center'},
						{field: 'num', title: '计划发货数量', align:'center'},
						{field: 'signCode', title: '透明标记编码', align:'center'},
					{field: 'ope', title: '操作', align:'center', width:380, templet:function(data){
							var returnStr = '';
							for(var i = 0; i < data.fileToumingbiaoArr.length; i++) {
								returnStr += '<a href="javascript:void(0);" class="layui-btn layui-btn-sm layui-btn-normal" onclick="doPrintTMB(\'' + data.fileToumingbiaoArr[i].link + '\')">打印透明标-' + (i + 1) + '</a>';
							}
							if (data.fileToumingbiaoArr.length === 0){
								returnStr += '<a href="javascript:void(0);" class="layui-btn layui-btn-sm layui-btn-normal">无透明标</a>';
							}
							return returnStr;
						}}
				] ],
				data: $.parseJSON(JSON.stringify([[${dto.rows}]])),
				done: function(){
				}
			});
		})
		</script>
	</form>
	<script>
	$(function () {
		layui.use(['form'], function(){
			var form = layui.form;
			
			// 表单提交，共用同一个
			form.on('submit(formSubmit)', function(data){
				var checkStatus = layui.table.checkStatus('id_table_fenxiang');
				var rows = checkStatus.data;
				if (rows.length <= 0) {
					layer.msg('请选择至少一条数据');
					return false;
				}
				//window.parent.tableOfShowingPerson.addRow(rows[0]);
				window.parent.tableOfShowingPerson.addRows(rows);
				var index = parent.layer.getFrameIndex(window.name);
				parent.layer.close(index);
				return false;
			});
		});
	});
	
	function doPrintTMB(urlPdf) {
		var json = {};
		json.action = "previewfile";	//打印指令动作。json.action = "preview"，则生成预览。
		json.format = "pdf_url";        //指定格式为pdf_url。 //指定格式为pdf_url。
		
		json.docwidth = 5; // 单位：cm
		json.doclength = 2.2; // 单位：cm
		json.paperwidth = 5;
		json.paperlength = 3;
		//json.margin3 = 0.5;
		//json.papersize = 1;
		
		json.content = urlPdf;   //pdf文件的url路径
		json.cert = window.location.href.split("//")[0] + "//" + window.location.host + "/js/printWorld/pdf_mini-ease.com.ctf";
		var pw = GetPrintWorld();    //获取打天下对象
		pw.Act(json);
	}
	</script>
</body>
</html>